#ifndef __KADEMLIA_SIMPLETAG__
#define __KADEMLIA_SIMPLETAG__

#include <string>
#include <list>

#include "Types.h"

// Groan.  Everything else is in std, so I guess we stay here.
namespace std {

class SimpleTag;

typedef std::list<SimpleTag> SimpleTagList;

class SimpleTag {
public:
  typedef enum {
    STRING_TYPE = 0,
    UINT32_TYPE = 1
  } TagType;

  SimpleTag(const std::string &stringValue);

  SimpleTag(uint32 uint32Value);

  void encode(byte **data) const;

  static size_t encodedTagListSize(const SimpleTagList &tagList);

  static void encodeTagList(const SimpleTagList &tagList, byte **data);

  static SimpleTag decode(byte **data);

  static SimpleTagList decodeTagList(byte **data);

  TagType getType() const;

  std::string getStringValue() const;

  uint32 getUint32Value() const;

private:

  void encodeType(byte **data) const;

  void encodeStringType(byte **data) const;

  void encodeUint32Type(byte **data) const;

  static TagType decodeType(byte **data);

  static std::string decodeStringType(byte **data);

  static uint32 decodeUint32Type(byte **data);

private:
  TagType type_;
  std::string stringValue_;
  uint32 uint32Value_;
};

}

#endif // __KADEMLIA_SIMPLETAG__

